
#ifndef PIU_CAST_HPP
#define PIU_CAST_HPP

#include <cstring>
#include <iostream>
#include <memory>
#include <mutex>
#include <sstream>

namespace piu
{
    template<class _Tp, class _Up>
    inline std::shared_ptr<_Tp> sharedPtrCast(const std::shared_ptr<_Up>& __r)
    {
        typedef typename std::shared_ptr<_Tp>::element_type _ET;
        _ET* __p = dynamic_cast<_ET*>((_ET*)__r.get());
        return __p ? std::shared_ptr<_Tp>(__r, __p) : std::shared_ptr<_Tp>();
    }
} // namespace piu

#endif //PIU_CAST_HPP
